<extend name="common:base" />

<block name="body">

    <div class="wrapper wrapper-content animated fadeInRight">        
        <div class="row">
            <div class="col-sm-6" style='width: 100%;'>
                <div class="ibox">
                    <div class="ibox-title">
                        <h5>权限菜单管理</h5>
                        <php>if($auth->check( 'admin/purview/add',  session('uid') )){</php>
                        <a href="{:U('admin/purview/add?pid=0')}" class="btn btn-info btn-xs" style='margin-left: 20px'>添加顶级菜单</a>
                        <php>}</php>
                        <a href="{:U('admin/auth/index')}" class="btn btn-info btn-xs">权限刷新</a>
                    </div>
                    <div class="ibox-content">
                        <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>id</th>
                                    <th>上级菜单</th>
                                    <th>链接</th>
                                    <th>名称</th>
                                    <th>类型</th>
                                    <th>状态</th>
                                    <th>规则</th>
                                    <php>if($auth->check( 'admin/purview/add',  session('uid') )||$auth->check( 'admin/purview/update',  session('uid') )||$auth->check( 'admin/purview/del',  session('uid') ) ){</php>
                                    <th>操作</th>
                                    <php>}</php>
                                </tr>
                            </thead>
                            <tbody>                                
                            {$menu}
                            </tbody>
                        </table>
                        </div>
                    </div>
                </div>
            </div>

            </div>

        </div>
    </div>
</block>
<block name="footer">
    <script>

        function confirm_submit(url,data,success){
            layer.confirm('确定删除吗？', {
                btn: ['确定','取消'], //按钮
            }, function(){
                $.ajax({
                    type:"post",
                    url:url,
                    data:data,
                    success:success
                })
            })
        }

        function del(id){
            confirm_submit("{:U('admin/purview/del')}","id="+id,showResponse1)
        }

        function add(pid){
            if(pid!=0){
                msg_url('不能添加子权限！')
            }
        }

        function showResponse1(responseText, statusText, xhr, $form){
            if(responseText.status=="0"){
                msg_url(responseText.info);
            }else{
                msg_url(responseText.info);
                window.setTimeout("location.reload()",1000);
            }
        }
    </script>
</block>
